﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Vouchers;

namespace Stock
{
    public class VoucherStockServiceFactory : IVoucherStockServiceFactory, ISingletonDependency
    {
        private readonly IServiceProvider _serviceProvider;
        public VoucherStockServiceFactory(IServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;
        }
        public IInVoucherStockService CreateInStock(VoucherTypeEnum voucherType)
        {
            return voucherType switch
            {
                VoucherTypeEnum.InStock => _serviceProvider.GetRequiredService<InStockVoucherService>(),
                _ => throw new ArgumentException($"Invalid voucher type: {voucherType}")
            };
        }

        public IOutVoucherStockService CreateOutStock(VoucherTypeEnum voucherType)
        {
            return voucherType switch
            {
                VoucherTypeEnum.OutStock => _serviceProvider.GetRequiredService<OutStockVoucherService>(),
                _ => throw new ArgumentException($"Invalid voucher type: {voucherType}")
            };
        }

        public IAllotVoucherStockService CreateAllotStock(VoucherTypeEnum voucherType)
        {
            return voucherType switch
            {
          
                VoucherTypeEnum.Allot => _serviceProvider.GetRequiredService<AllotVoucherService>(),
                _ => throw new ArgumentException($"Invalid voucher type: {voucherType}")
            };
        }
    }
}
